package com.fosu.web.controller;


import com.alibaba.fastjson.JSONObject;
import com.fosu.common.ResponseResult;
import com.fosu.interceptor.PublishInterceptor;
import com.fosu.service.PublishService;

import com.fosu.Utils.ThreadLocal2JsonObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;




/**
 * @author zqa
 * @version 1.0
 * @date 2020/10/19 15:43
 */

@RestController
@RequestMapping("/release")
public class PublishController {
    @Autowired
    PublishService publishService;



    @Autowired
    PublishInterceptor publishInterceptor;
    @RequestMapping(value = "/findProductCategories")
    public ResponseResult findProductCategories( HttpServletResponse resp) throws Exception {

        return publishService.findAll(resp);
    }


    @RequestMapping(value = "/releaseProduct",method = RequestMethod.POST)

    public ResponseResult releaseProduct( HttpServletRequest request,HttpServletResponse resp) throws Exception {

       return publishService.save(request,resp, ThreadLocal2JsonObjectUtil.getJSONObject());
    }

    @RequestMapping("/updateProduct")
    @ResponseBody
    public ResponseResult updateProduct(@RequestBody JSONObject jsonPram, HttpServletRequest request, HttpServletResponse resp) throws Exception {

        return publishService.update(request,resp,jsonPram);
    }

}
